import { TRuneManual } from "../../../../../../Message/Db/Tables/TRuneManual";
import { RuneManualConfig } from "../../../../resource/RuneManualConfig";
import { SkillRuneHandbookHolyItem } from "./SkillRuneHandbookHolyItem";
import { SkillRuneHandbookNormalItem } from "./SkillRuneHandbookNormalItem";
import { ObjCreate } from "../../../common/ObjCreate";
import { PageSelecter } from "../../../common/pageSelect/PageSelecter";
type int = number;
//class SkillRuneHandbookRightPart
    
    export  class SkillRuneHandbookRightPart /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initView();
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            this._data = arg1;
            var loc1=this._data.length;
            var loc2=loc1 / this.PageSize;
            if (loc1 % this.PageSize != 0) 
            {
                ++loc2;
            }
            this._selector.maxPage = loc2;
            this._selector.currentPage = 1;
            this.gotoPage(1);
            return;
        }

        /* internal  */pageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._selector.currentPage;
            this.gotoPage(loc1);
            return;
        }

        /* internal  */gotoPage(arg1: int): void
        {
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc1=(arg1 - 1) * this.PageSize;
            var loc2=0;
            this.visibalAll = false;
            var loc3=loc1;
            while (loc3 < loc1 + this.PageSize && loc3 < this._data.length) 
            {
                if ((loc4 = this._data[loc3] as TRuneManual) != null) 
                {
                    if (RuneManualConfig.instance.isHolyRune(loc4)) 
                    {
                        (loc5 = this._holys[loc2] as SkillRuneHandbookHolyItem).update(loc4);
                        loc5.visible = true;
                    }
                    else 
                    {
                        (loc6 = this._normals[loc2] as SkillRuneHandbookNormalItem).update(loc4);
                        loc6.visible = true;
                    }
                }
                ++loc3;
                ++loc2;
            }
            return;
        }

        /* internal  */set visibalAll(arg1: Boolean)
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this.PageSize) 
            {
                loc2 = this._holys[loc1] as SkillRuneHandbookHolyItem;
                loc2.visible = arg1;
                loc2 = this._normals[loc1] as SkillRuneHandbookNormalItem;
                loc2.visible = arg1;
                ++loc1;
            }
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=0;
            var loc2=null;
            this._holys = [];
            loc1 = 0;
            while (loc1 < this.PageSize) 
            {
                loc2 = new SkillRuneHandbookHolyItem();
                loc2.x = 0;
                loc2.y = loc1 * 134;
                this.addChild(loc2);
                this._holys.push(loc2);
                ++loc1;
            }
            this._normals = [];
            loc1 = 0;
            while (loc1 < this.PageSize) 
            {
                loc2 = new SkillRuneHandbookNormalItem();
                loc2.x = 0;
                loc2.y = loc1 * 134;
                this.addChild(loc2);
                this._normals.push(loc2);
                ++loc1;
            }
            this.visibalAll = false;
            this._selector = ObjCreate.createPageSelecter(192, 410, this, PageSelecter.CompleteMode);
            this._selector.addEventListener(flash.events.Event.CHANGE, this.pageChangeHandler);
            return;
        }

        /* internal */ /* const */PageSize: int=3;

        /* internal */ /* var */_holys: Array<any>;

        /* internal */ /* var */_normals: Array<any>;

        /* internal */ /* var */_data: Array<any>;

        /* internal */ /* var */_selector: PageSelecter;
    }
